from app.schemas import StandardResponse
from pydantic import BaseModel, Field
from shared_data.robot import DISCOVER_FLEX_EXAMPLE
from typing import Any, Dict, Optional
from .common_response import CommonFailResponse


class GetDateData(BaseModel):
    date: str


class GetDateResponse(StandardResponse):
    data: GetDateData = Field(..., description="Current date in a robot")


class DiscoverFlexData(BaseModel):
    number: int
    flex_groups: Dict[str, Any]


class DiscoverFlexResponse(StandardResponse):
    data: DiscoverFlexData = Field(..., description="Discover flex",
                                   examples=[DISCOVER_FLEX_EXAMPLE])

class UpdateDateData(BaseModel):
    old_date: str = Field(..., description="old date")
    now_date: str = Field(..., description="the date after requesting")


class UpdateDateResponse(StandardResponse):
    data: UpdateDateData = Field(..., description="Current date in a robot")


class HomeRequest(BaseModel):
    host_name: str = Field(..., description="robot ip address")
    mount: Optional[str] = Field(
        default=None,
        description="The mount to home, if mount set default, only home robot, but mount is sat, only home robot")

def get_expected_response_v1(response):
    v1 = {
        200: {"description": "Success", "model": response},
        406: {"description": "Fail", "model": CommonFailResponse},
        400: {"description": "Unknow", "model": CommonFailResponse},
    }
    return v1